package edu.zut.servlet;

import edu.zut.pojo.SysUser;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "JSPServlet", value = "/jsp/demo1")
public class JSPServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setAttribute("myName","xueyin");
        HttpSession session = request.getSession();
        session.setAttribute("mySchool","河南财经政法大学");
        session.setAttribute("myName","xuexiaoyin");
        ServletContext servletContext = request.getServletContext();
        servletContext.setAttribute("myAddress","河南省新乡市");

        SysUser sysUser = new SysUser();
        sysUser.setName("xiaoyin");
        sysUser.setAge(20);
        request.setAttribute("sysUser",sysUser);

        //转发demo1.jsp
        request.getRequestDispatcher("/demo1.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
